import { defineStore } from 'pinia';

export const useGlobalStore = defineStore('globalInfo', {
  state: () => ({
    menus: [] , // 存储后台查询的菜单
    userInfo:{},//存储用户信息
    perms:[],
    roles:[],
    token:''
  }),
  actions: {
    setMenus(menus) {
      this.menus = menus;
    },
    setUserInfo(userInfo) {
      this.userInfo = userInfo;
    },
  },
//   getters: {
//     // 获取用户信息
//     getUserInfo: (state) => state.userInfo,
//     // 获取菜单
//     getMenus: (state) => state.menus,
//     //获取状态
//     getLoadStatus:(state)=>state.loadStatus
//   },
  //persist: true, // 开启持久化
  persist: {
    storage: sessionStorage, // 使用 sessionStorage存储  默认是localstorage
  }
});